<template>
  <div id="app">
    <br />
    <!-- 其中type属性控制的是颜色，icon是图标
              primary是蓝色        
              success是绿色
              info是灰色
              warning是黄色
              danger是红色
            -->
    <!-- <el-row>
        <el-button icon="el-icon-search" circle @click="changeflag" ></el-button>
        <input type="text" v-show="isflag" v-model="arrays">
        <el-button type="primary" icon="el-icon-edit" circle @click="changeflagA"></el-button>
       
        <el-button type="success" icon="el-icon-check" circle @click="changeflagB"></el-button>
        <el-button type="info" icon="el-icon-message" circle></el-button>
        <el-button type="warning" icon="el-icon-star-off" circle></el-button>
        <el-button type="danger" icon="el-icon-delete" circle></el-button>   
         
  
        <br>
            <textarea v-show="isflagA" v-model="arrays"></textarea> -->
    <!-- <Message ></Message> -->
    <!-- <List v-show="isflagB"></List>
             
      </el-row> -->
    <el-form class="login-container" label-position="left" label-width="0px">
      <h3 class="login_title">系统注册</h3>
      <el-form-item>
        <el-input
          type="text"
          v-model="registerForm.username"
          auto-complete="off"
          placeholder="账号"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-input
          type="password"
          v-model="registerForm.password"
          auto-complete="off"
          placeholder="密码"
        ></el-input>
      </el-form-item>
      <el-form-item style="width: 100%">
        <el-button
          type="primary"
          style="width: 100%; background: #505458; border: none"
          v-on:click="register"
          >登录</el-button
        >
      </el-form-item>
    </el-form>
    <br />
    <!-- <router-link class="home" to="/home">Home</router-link>|
      <keep-alive include="News">
      <router-view></router-view>
      </keep-alive> -->
  </div>
</template>
<script>
export default {
  name: "Register",
  data() {
    return {
      registerForm: [
        {
          username: "",
          password: "",
        },
      ],
    };
  },
  methods: {
    register() {
      console.log(1111111);
      this.$axios
        .post("/register", {
          username: this.registerForm.username,
          password: this.registerForm.password,
        })
        .then((successResponse) => {
          if (successResponse.data.code === 200) {
            // var data = this.loginForm
            // this.$store.commit("login", this.loginForm);
            // var path = this.$route.query.redirect;
            this.$router.replace({
              path: "/login",
            });
          } else if (successResponse.data.code === 401) {
            alert("请填写账号");
          } else if (successResponse.data.code == 402) {
            alert("请填写密码");
          } else if (successResponse.data.code == 500) {
            alert("注册失败");
          } else if (successResponse.data.code == 404) {
            alert("已经存在该用户名,请换一个新的")
          }
          else {
            alert("请输入账号和密码");
          }
        });
    },
  },
};
</script>
<style scoped>
.login-container {
  border-radius: 15px;
  background-clip: padding-box;
  margin: 300px auto;
  width: 350px;
  padding: 35px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 25px #cac6c6;
}

.login_title {
  margin: 0px auto 40px auto;
  text-align: center;
  color: #505458;
}
#app {
  background: url("../assets/eva.jpg") no-repeat;
  background-position: center;
  height: 100%;
  width: 100%;
  background-size: cover;
  position: fixed;
}
div {
  margin: 0;
}
</style>